package com.ruoyi.odorservice.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.odorservice.entity.MaterialOdor;
import com.ruoyi.odorservice.entity.Odor;
import com.ruoyi.odorservice.model.vo.OdorMaterialVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OdorMapper extends BaseMapper<Odor> {

    /**
     * 根据气味id集合查询气味名称与对应物质集合
     * @param ids
     * @return
     */
    List<OdorMaterialVo> selectOdorListByIds(@Param("ids") List<Integer> ids);

    /**
     * 批量插入
     * @param materialOdorList
     * @return
     */
    int insertBatchMaterialOdor(@Param("materialOdorList") List<MaterialOdor> materialOdorList);

    /**
     * 根据气味名称查询气味
     * @param odorName
     * @return
     */
    @Select("SELECT * FROM odor_info WHERE odor_name = #{odorName}")
    Odor selectOdorByOdorName(@Param("odorName") String odorName);

    /**
     * 根据气味id删除对应物质
     * @param odorId
     * @return
     */
    @Delete("DELETE FROM odor_material_odor WHERE odor_id = #{odorId}")
    int deleteMaterialOdorByOdorId(@Param("odorId") Integer odorId);
}
